Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does it do?
CC @artkaseman Before, we were NOT using the snapshot of validator state at the time of validator selection for payout distribution. Instead, we were using the
CandidateState
at the time of the delayed payment to determine payout distribution. This means nominators that left before the payout distribution were not paid and, more dangerously, new nominators that joined during the delay were paid instead even though they weren't nominators at the time of the validator's block author reward.Note that this PR also removes
pallet-staking
as a dependency. We may add this back if we choose to use theExposure
type when we implement slashing, but we don't need it now. I replaced it withValidatorSnapshot
which provides a snapshot of the state of the validator at the time they are selected for the round.What important points reviewers should know?
Context
due_proportion
is actors_stake/total_validator_stake * total_due_issuance_for_the_validatorThe bug used the current
CandidateState
to calculate distribution of rewards earned 2 rounds prior. This means nominators that left before the payout distribution were not paid and, more dangerously, new nominators that joined during the delay were paid instead even though they weren't nominators at the time of the validator's block author reward.The fix snapshots
CandidateState
at the time the account is chosen for the round so it can weight the earnings distribution based on this snapshot instead of on the currentCandidateState
(which could easily have changed between the time the block author was recognized and the payout was executed).Is there something left for follow-up PRs?
What alternative implementations were considered?
Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?
What value does it bring to the blockchain users?
Checklist